package demo;

import javax.xml.parsers.*;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.*;

public class GetDom {

	static final String ARCHIVO = "empleados.xml";
	
	void parseXML(){
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		try {
			DocumentBuilder builder = factory.newDocumentBuilder();
			Document doc = builder.parse(ARCHIVO);
			TransformerFactory tranFact = TransformerFactory.newInstance(); 
			Transformer transfor = tranFact.newTransformer(); 
			Node node =doc.getDocumentElement();
			Source src = new DOMSource(node); 
			Result dest = new StreamResult(System.out);
			transfor.transform(src, dest);
		} catch (Exception e) {
			e.printStackTrace();
		}
		

	}
	
	public static void main(String[] args) {
		GetDom ins = new GetDom();
		ins.parseXML();
	}
}
